<div class="container-fluid">
    <div class="wrapper">
        <div class="panel" id="nav">
            <div class="panel-heading"><h3 class="panel-title">已采购待收货的采购单查询</h3></div>
            <div class="panel-body">
                <form action="__URL__/purchased_wait_recieve" method="get">
                    <div class="container-fluid">
                        <div class="col-sm-12 col-md-3  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">SKU</span>
                                <input class="form-control" type="text" name="sku">
                            </div>
                        </div>


                        <div class="col-sm-12 col-md-3  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">采购员</span>
                                <input type="text" name="purchase_id" class="form-control" value="">
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-3  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">供应商</span>
                                <input type="text" name="supplier_id" class="form-control" value="">
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-3  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">采购单号</span>
                                <input type="text" name="id" class="form-control" value="">
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-6  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">采购日期</span>
                                <input class="form-control form-date" type="text" name="purchase_time_from"
                                       style="cursor:pointer;" readonly>
                                <span class="input-group-addon"><span class="icon-calendar"></span></span>
                                <input class="form-control form-date" type="text" name="purchase_time_to"
                                       style="cursor:pointer;" readonly>
                            </div>
                        </div>
                        <div class="col-md-3 add-space">
                            <input class="btn btn-primary" type="submit" value="查询">
                            <input class="btn btn-primary" type="button" onclick="reset()" value="重置">
                            <input class="btn btn-primary" type="button" id="download" value="下载">
                        </div>
                    </div>
                </form>
                <div class="clearfix"></div>
                <hr>
                <table class="table table-striped  table-hover" cellspacing="0" width="100%">
                    <thead>
                    <tr>
                        <th>采购单号</th>
                        <th>退税类型</th>
                        <th>SKU</th>
                        <th>中文名称</th>
                        <th>规格</th>
                        <th>储位</th>
                        <th>供应商</th>
                        <th>采购员</th>
                        <th>采购数量</th>
                        <th>采购时间</th>
                        <th>采购明细单状态</th>
                        <th>采购类型</th>
                        <th>已到货数量</th>
                        <th>已入库量</th>
                        <th>退回量</th>
                        <th>站点</th>
                        <th>备注</th>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="data" id="val">
                        <tr>
                            <td>{$val.id}</td>
                            <td>{$val.export_tax_rebate}</td>
                            <td>{$val.sku}</td>
                            <td>{$val.sku_name}</td>
                            <td>{$val.sku_standard}</td>
                            <td>{$val.storage_position}</td>
                            <td>{$val.supplier_id}</td>
                            <td>{$val.purchase_id}</td>
                            <td>{$val.quantity}</td>
                            <td>{$val.purchase_time}</td>
                            <td>{$val.status}</td>
                            <td>{$val.createtype}</td>
                            <td>{$val.recieve_quantity}</td>
                            <td>{$val.ware_quantity}</td>
                            <td>{$val.return_quantity}</td>
                            <td>{$val.site_id}</td>
                            <td>{$val.remark}</td>
                        </tr>
                    </volist>

                </table>
                <div class="clearfix clear"></div>
                <div class="row">
                    <div class="col-md-6 pull-left">
                        <label>每页 20 条记录
                            显示 1 到 20 项，共 {$count}项</label>
                    </div>
                    <div class="col-md-6">
                        <div class="page pull-right" style="padding: 0;margin: 0">
                            {$page}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $("input[name='sku']").val("<?php  echo $_GET['sku'];?>");
        $("input[name='purchase_id']").val("<?php echo $_GET['purchase_id'];?>");
        $("input[name='id']").val("<?php echo $_GET['id'];?>");
        $("input[name='supplier_id']").val("<?php echo $_GET['supplier_id'];?>");
        $("input[name='purchase_time_from']").val("<?php  echo $_GET['purchase_time_from'];?>");
        $("input[name='purchase_time_to']").val("<?php  echo $_GET['purchase_time_to'];?>");

    });

    /**
     * 重置
     * */
    function reset() {
        $('#form_search').find('input').val('');
        $('#form_search').find('select').val('');
    }


    /**
     * 下载
     */
    $("#download").click(function () {
        var param = '';
        var sku = $("input[name='sku']").val();
        var purchase_id = $("input[name='purchase_id']").val();
        var id = $("input[name='id']").val();
        var supplier_id = $("input[name='supplier_id']").val();
        var purchase_time_from = $("input[name='purchase_time_from']").val();
        var purchase_time_to = $("input[name='purchase_time_to']").val();

        if ($.trim(sku) != '') {
            param += "&sku=" + sku;
        }
        if ($.trim(purchase_id) != '') {
            param += "&purchase_id=" + purchase_id;
        }
        if ($.trim(id) != '') {
            param += "&id=" + id;
        }
        if ($.trim(supplier_id) != '') {
            param += "&supplier_id=" + $.trim(supplier_id);
        }
        if ($.trim(purchase_time_from) != '') {
            param += "&purchase_time_from=" + $.trim(purchase_time_from);
        }
        if ($.trim(purchase_time_from) != '') {
            param += "&purchase_time_to=" + $.trim(purchase_time_to);
        }
        if (param != '') {
            param = '?' + param.substr(1);
        }
        window.location.href = '__URL__/purchased_wait_recieve_download' + param;
    });

</script>
